/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jholmedia.transindica;

import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.pdfbox.pdmodel.PDDocument;
import org.pdfbox.util.PDFTextStripper;

/**
 *
 * @author kinjal
 */
public class Extract {

    private String outputFolder;
    private String inputFolder;

    public void setOutputFolder(String outputFolder) {
        this.outputFolder = outputFolder;
    }

    public void setInputFolder(String inputFolder) {
        this.inputFolder = inputFolder;
    }

    public void extract(String sourceFile, String targetFile) {
        try {
            PDDocument doc = PDDocument.load(inputFolder+sourceFile);
            PDFTextStripper source=new PDFTextStripper();
            Writer target = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFolder+targetFile)));
            source.writeText(doc, target);
            target.close();
            doc.close();
        } catch (IOException ex) {
            Logger.getLogger(Extract.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
